package lab2;

/**
 * Created by Administrator on 2017/10/12.
 */
import java.util.*;
import java.io.*;
public class Text1 {
    public static void main(String args[]) throws IOException
    {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("请输入你的生日(例如:2011 1 1):");
        StringTokenizer	str =new StringTokenizer(input.readLine());
        int d[]=new int[3];
        int i=0;
        while(str.hasMoreTokens())
        {
            d[i]=Integer.parseInt(str.nextToken());
            i++;
        }
        System.out.print("你的生日距离现在有");
        System.out.println(returnDay(d[0],d[1],d[2])+"天");
    }
    public static int returnDay(int year,int month,int day)
    { Calendar date=Calendar.getInstance();
        int months[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
        int tmpyear=year;
        int y=date.get(Calendar.YEAR);
        int m=date.get(Calendar.MONTH)+1;
        int d=date.get(Calendar.DAY_OF_MONTH);
        int runnian=0;
        int totalDay=0;
        while(tmpyear<y)
        {
            if(((tmpyear % 4 == 0)&&(tmpyear % 100 != 0)) || (tmpyear % 400 == 0))
            {
                runnian++;
            }
            tmpyear++;
        }
        totalDay=((y-year-runnian)*365)+(runnian*366);
        for(int i=month;i<m;i++)
        {
            totalDay+=months[i];
        }
        if(((y % 4 == 0)&&(y % 100 != 0)) || (y % 400 == 0))	{	if(m>2 || d==29)
        {
            totalDay++;
        }
        }
        totalDay += d-day;
        return totalDay;
    }
}

